import uuid

uuid1 = uuid.uuid1()
uuid4 = uuid.uuid4()

print(uuid1, uuid4)


def generateData():
    for val in range(1, 4):
        yield val
generate = generateData()
print(next(generate))
print(next(generate))
print(next(generate))

for val in generateData():
    print(val)



# map or lambda
def f(x):
    return x * x
print(list(map(f, range(1, 7)))) # [1, 4, 9, 16, 25, 36]

print(list(map(lambda x: x * x, range(1, 7)))) # [1, 4, 9, 16, 25, 36]


from functools import reduce
def add(x, y):
    return x + y
print(reduce(add, range(1, 10))) # 45

print(reduce(lambda x, y: x + y, range(1, 10))) # 45

def is_odd(n):
    return n % 2 == 0
print(list(filter(is_odd, range(1, 10)))) # [2, 4, 6, 8]

print(list(filter(lambda x: x % 2 == 0, range(1, 10)))) # [2, 4, 6, 8]


def ownSort(n):
    return str(abs(n))[0]

sortList = [-3, 9, -7, 10]
print(sorted(sortList)) # [-7, -3, 9, 10]
print(sorted(sortList, key=abs)) # [-3, -7, 9, 10]
print(sorted(sortList, key=abs, reverse=True)) # [10, 9, -7, -3]
print(sorted(sortList, key=ownSort)) # [10, -3, -7, 9]

